package com.mt.roll.wms.controller;

import com.mt.roll.core.base.BaseController;
import com.mt.roll.core.constants.CommonConstant;
import com.mt.roll.core.dal.entity.WorkOrder;
import com.mt.roll.core.params.IdParam;
import com.mt.roll.core.validator.groups.AddGroup;
import com.mt.roll.core.validator.groups.PageGroup;
import com.mt.roll.core.vo.IdVo;
import com.mt.roll.core.vo.PageVo;
import com.mt.roll.core.vo.R;
import com.mt.roll.wms.params.GradeInformationParam;
import com.mt.roll.wms.params.StorageBoxCircInfoQueryParam;
import com.mt.roll.wms.params.WorkOrderParam;
import com.mt.roll.wms.params.WorkOrderQueryParam;
import com.mt.roll.wms.service.WorkOrderService;
import com.mt.roll.wms.vo.StorageBoxCircInfoVo;
import com.mt.roll.wms.vo.WorkOrderVo;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.validation.groups.Default;

/**
 * @auther why
 * @date 2021/10/18 9:24
 */
@RestController
@RequestMapping(CommonConstant.API_MODULE_WMS + "work/order")
@Slf4j
@Api(value = "工单信息", tags = "工单信息", hidden = false)
public class WorkOrderController extends BaseController {

    @Autowired
    private WorkOrderService workOrderService;

    @PostMapping(value = "page")
    @ApiOperation(value = "获取分页工单")
    private R<PageVo<WorkOrder>> page(@Validated({PageGroup.class, Default.class}) @RequestBody WorkOrderQueryParam workOrderQueryParam) {
        return workOrderService.page(workOrderQueryParam);
    }

    @PostMapping(value = "get")
    @ApiOperation(value = "获取工单详情")
    private R<WorkOrder> get(@Validated @RequestBody IdParam idParam) {
        return workOrderService.get(idParam);
    }

    @PostMapping(value = "update")
    @ApiOperation(value = "update工单信息")
    private R<IdVo> update(@Validated({AddGroup.class, Default.class}) @RequestBody WorkOrderParam workOrderParam) {
        return workOrderService.update(workOrderParam);
    }

    @PostMapping(value = "oob/to/ooa/work/order")
    @ApiOperation(value = "OOB->OOA工单信息")
    private R<IdVo> oobToOoaWorkOrder(@Validated({AddGroup.class, Default.class}) @RequestBody WorkOrderParam workOrderParam) {
        return workOrderService.oobToOoaWorkOrder(workOrderParam);
    }

}
